package Java网络实例;

import java.net.InetAddress;
public class 获取本机ip地址及主机名 {
public static void main(String[] args)throws Exception {
	
          InetAddress addr = InetAddress.getLocalHost();
          System.out.println("Local HostAddress:"+addr.getHostAddress());
          String hostname = addr.getHostName();
          System.out.println("Local host name: "+hostname);
       }
}
